using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class MarginType_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            FieldInfo field;
            Type[] args;
            Type type = typeof(global::MarginType);

            field = type.GetField("None", flag);
            app.RegisterCLRFieldGetter(field, get_None_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_None_0, null);
            field = type.GetField("Margin", flag);
            app.RegisterCLRFieldGetter(field, get_Margin_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_Margin_1, null);
            field = type.GetField("MarginRatio", flag);
            app.RegisterCLRFieldGetter(field, get_MarginRatio_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_MarginRatio_2, null);
            field = type.GetField("MarginX", flag);
            app.RegisterCLRFieldGetter(field, get_MarginX_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_MarginX_3, null);
            field = type.GetField("MarginY", flag);
            app.RegisterCLRFieldGetter(field, get_MarginY_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_MarginY_4, null);
            field = type.GetField("MarginRatioX", flag);
            app.RegisterCLRFieldGetter(field, get_MarginRatioX_5);
            app.RegisterCLRFieldBinding(field, CopyToStack_MarginRatioX_5, null);
            field = type.GetField("MarginRatioY", flag);
            app.RegisterCLRFieldGetter(field, get_MarginRatioY_6);
            app.RegisterCLRFieldBinding(field, CopyToStack_MarginRatioY_6, null);
            field = type.GetField("Size", flag);
            app.RegisterCLRFieldGetter(field, get_Size_7);
            app.RegisterCLRFieldBinding(field, CopyToStack_Size_7, null);
            field = type.GetField("Ratio", flag);
            app.RegisterCLRFieldGetter(field, get_Ratio_8);
            app.RegisterCLRFieldBinding(field, CopyToStack_Ratio_8, null);
            field = type.GetField("SizeX", flag);
            app.RegisterCLRFieldGetter(field, get_SizeX_9);
            app.RegisterCLRFieldBinding(field, CopyToStack_SizeX_9, null);
            field = type.GetField("SizeY", flag);
            app.RegisterCLRFieldGetter(field, get_SizeY_10);
            app.RegisterCLRFieldBinding(field, CopyToStack_SizeY_10, null);
            field = type.GetField("RatioX", flag);
            app.RegisterCLRFieldGetter(field, get_RatioX_11);
            app.RegisterCLRFieldBinding(field, CopyToStack_RatioX_11, null);
            field = type.GetField("RatioY", flag);
            app.RegisterCLRFieldGetter(field, get_RatioY_12);
            app.RegisterCLRFieldBinding(field, CopyToStack_RatioY_12, null);


            app.RegisterCLRCreateDefaultInstance(type, () => new global::MarginType());
            app.RegisterCLRCreateArrayInstance(type, s => new global::MarginType[s]);


        }

        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList<object> __mStack, ref global::MarginType instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch(ptr_of_this_method->ObjectType)
            {
                case ObjectTypes.Object:
                    {
                        __mStack[ptr_of_this_method->Value] = instance_of_this_method;
                    }
                    break;
                case ObjectTypes.FieldReference:
                    {
                        var ___obj = __mStack[ptr_of_this_method->Value];
                        if(___obj is ILTypeInstance)
                        {
                            ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            var t = __domain.GetType(___obj.GetType()) as CLRType;
                            t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                        }
                    }
                    break;
                case ObjectTypes.StaticFieldReference:
                    {
                        var t = __domain.GetType(ptr_of_this_method->Value);
                        if(t is ILType)
                        {
                            ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                        }
                        else
                        {
                            ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                        }
                    }
                    break;
                 case ObjectTypes.ArrayReference:
                    {
                        var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as global::MarginType[];
                        instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
                    }
                    break;
            }
        }


        static object get_None_0(ref object o)
        {
            return global::MarginType.None;
        }

        static StackObject* CopyToStack_None_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.None;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Margin_1(ref object o)
        {
            return global::MarginType.Margin;
        }

        static StackObject* CopyToStack_Margin_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.Margin;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_MarginRatio_2(ref object o)
        {
            return global::MarginType.MarginRatio;
        }

        static StackObject* CopyToStack_MarginRatio_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.MarginRatio;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_MarginX_3(ref object o)
        {
            return global::MarginType.MarginX;
        }

        static StackObject* CopyToStack_MarginX_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.MarginX;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_MarginY_4(ref object o)
        {
            return global::MarginType.MarginY;
        }

        static StackObject* CopyToStack_MarginY_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.MarginY;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_MarginRatioX_5(ref object o)
        {
            return global::MarginType.MarginRatioX;
        }

        static StackObject* CopyToStack_MarginRatioX_5(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.MarginRatioX;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_MarginRatioY_6(ref object o)
        {
            return global::MarginType.MarginRatioY;
        }

        static StackObject* CopyToStack_MarginRatioY_6(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.MarginRatioY;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Size_7(ref object o)
        {
            return global::MarginType.Size;
        }

        static StackObject* CopyToStack_Size_7(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.Size;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_Ratio_8(ref object o)
        {
            return global::MarginType.Ratio;
        }

        static StackObject* CopyToStack_Ratio_8(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.Ratio;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_SizeX_9(ref object o)
        {
            return global::MarginType.SizeX;
        }

        static StackObject* CopyToStack_SizeX_9(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.SizeX;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_SizeY_10(ref object o)
        {
            return global::MarginType.SizeY;
        }

        static StackObject* CopyToStack_SizeY_10(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.SizeY;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_RatioX_11(ref object o)
        {
            return global::MarginType.RatioX;
        }

        static StackObject* CopyToStack_RatioX_11(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.RatioX;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static object get_RatioY_12(ref object o)
        {
            return global::MarginType.RatioY;
        }

        static StackObject* CopyToStack_RatioY_12(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = global::MarginType.RatioY;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


        static object PerformMemberwiseClone(ref object o)
        {
            var ins = new global::MarginType();
            ins = (global::MarginType)o;
            return ins;
        }


    }
}
